﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Ewk.Math.Algebra.UnitTests.MatrixTests.NumericTests
{
    [TestClass]
    public abstract class AddTestBase<T> : NumericTestBase<T>
        where T : struct, IComparable, IFormattable, IConvertible, IComparable<T>, IEquatable<T>
    {
        [TestMethod]
        public void Add_performs_an_add_to_each_element()
        {
            var matrix = Matrix;
            var number = Two;
            matrix.Add(number);

            var iValue = One;
            for (var i = 0; i < matrix.RowCount; i++)
            {
                var jValue = One;
                for (var j = 0; j < matrix.ColumnCount; j++)
                {
                    Assert.AreEqual((iValue * jValue) + number, matrix[i, j].Value);
                    jValue++;
                }
                iValue++;
            }
        }

        [TestMethod]
        public void Add_performs_an_add_of_two_matrixes()
        {
            var matrix1 = Matrix;
            var matrix2 = Matrix;
            matrix1.Add(matrix2);

            var iValue = One;
            for (var i = 0; i < matrix1.RowCount; i++)
            {
                var jValue = One;
                for (var j = 0; j < matrix1.ColumnCount; j++)
                {
                    Assert.AreEqual(iValue * jValue * Two, matrix1[i, j].Value);
                    jValue++;
                }
                iValue++;
            }
        }
    }
}